package errcode

type ErrCode int

const (
	OK   ErrCode = 200
	FAIL ErrCode = 400
)

const (
	NOT_ACCEPTABLE_PARA ErrCode = 4000 + iota
)

const (
	MONITOR_INTERFACE_ERR ErrCode = 5000 + iota
	MONITOR_PARSE_MAC_ERR
	MONITOR_GET_IP_ERR
)

const (
	DDNS_NOIP_REQUEST_ERR ErrCode = 6000 + iota
	DDNS_NOIP_UPDATE_FAILED
	DDNS_DYNV6_REQUEST_ERR
	DDNS_DYNV6_UPDATE_FAILED
	DDNS_NO_NEED_TO_UPDATE
)

const (
	NOTIFY_SERVERCHAN_JSON_ERR ErrCode = 7000 + iota
	NOTIFY_SERVERCHAN_POST_ERR
	NOTIFY_MAIL_SEND_ERR
)

var msg = map[ErrCode]string{
	OK:   "成功",
	FAIL: "失败",

	NOT_ACCEPTABLE_PARA: "para参数参数",

	MONITOR_INTERFACE_ERR: "监控器接口失败",
	MONITOR_PARSE_MAC_ERR: "监控器解析MAC地址失败",
	MONITOR_GET_IP_ERR:    "监控器获取IP失败",

	DDNS_NOIP_REQUEST_ERR:    "DDNS-NOip请求失败",
	DDNS_NOIP_UPDATE_FAILED:  "DDNS-NOip更新IP失败",
	DDNS_DYNV6_REQUEST_ERR:   "DDNS-Dynv6请求失败",
	DDNS_DYNV6_UPDATE_FAILED: "DDNS-Dynv6更新失败",
	DDNS_NO_NEED_TO_UPDATE:   "未检测到变更，无需更新",

	NOTIFY_SERVERCHAN_JSON_ERR: "NOTIFY-server酱json错误",
	NOTIFY_SERVERCHAN_POST_ERR: "NOTIFY-server酱post请求错误",
	NOTIFY_MAIL_SEND_ERR:       "NOTIFY-mail发送失败",
}

func GetCodeMsg(code ErrCode) string {
	return msg[code]
}
